package com.zanfeng.signleplatform.dao.persistence.dao;

import com.zanfeng.signleplatform.api.result.modules.permission.PermissionResult;
import com.zanfeng.signleplatform.base.BaseMapper;
import com.zanfeng.signleplatform.dao.persistence.entity.Permission;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;

import java.util.List;
import java.util.Map;

public interface PermissionMapper extends BaseMapper<Permission> {

    //  列表查询
    List<com.zanfeng.signleplatform.api.result.modules.permission.PermissionResult> queryPermissionList(Map paramMap);

    //  根据ID列表逻辑删除
    void deletePermissionListByIdList(List<Integer> idList);

    // 根据权限名查询权限信息
    @Select("select * from wt_permission WHERE permission_code = #{permissionCode} AND is_delete = 0 and module_id = #{moduleId} limit 1")
    Permission findPermissionByCodeAndModuleId(@Param("moduleId") Integer moduleId, @Param("permissionCode") String permissionCode);

    //  获取全部可用的权限
    @Select("SELECT * FROM wt_permission WHERE is_publish = 1 AND is_delete = 0 ORDER BY module_id ,order_num DESC, permission_code")
    List<PermissionResult> queryPermissionResultActivedList();
}